package com.wjf.birdfish.util;

import java.io.InputStream;
import java.util.*;
import java.util.Map.Entry;

/**
 * @author 
 *
 * 读入配置文件
 * 
 * <a href="malito:tongys@tydic.com">童永胜</a>
 * 
 * 进行优化 将getPropertyByStr方法改为静态方法，新加入getPropertyByInt方法
 */
public final class JDBCProperties {

	private static final Properties properties;

	static {
		properties = new Properties();
		InputStream stream =
			JDBCProperties.class.getResourceAsStream("/jdbc.properties");
		try {
			properties.load(stream);
		} catch (Exception e) {

		}
		properties.putAll(System.getProperties());
	}
	/**
	 * @param propertyName :对象名称
	 * @return 对象值
	 * 取得配置文件的对象值
	 */
	public static String getPropertyByStr(String propertyName) {
		return String.valueOf(JDBCProperties.properties.get(propertyName));
	}

	/**
	 * @return List<所有对象的值>对象值
	 * 取得配置文件的对象值
	 */
	public static List getPropertyNames(){
		List list=new ArrayList();
		Entry<String, String> e = null;
		Iterator it = properties.entrySet().iterator(); 
		while(it.hasNext()){
			e=(Entry<String, String>) it.next();
			if(StringHelper.checkInt(e.getKey()))
				list.add(e.getKey());
		}
		return list;
	}
	public static void main(String[] args){
		//System.out.println("value="+Chinese.toChinese((ReadProperties.getPropertyByStr("1000"))));
		JDBCProperties.getPropertyNames();
	}
}
